package com.example.barcodeapp.ui.home;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.barcodeapp.R;

public class ShiJianAdapter extends RecyclerView.Adapter<ShiJianAdapter.ViewHolder> {
    Context context;


    public ShiJianAdapter(Context context) {
        this.context = context;
    }
    public String setText;

    public ShiJianAdapter(Context context, String setText) {
        this.context = context;
        this.setText = setText;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.adapter_shijian, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.shijianTv.setText(setText);
        if (position == 2) {
            holder.shijianTv.setTextColor(Color.parseColor("#A3A3A3"));
        } else if (position == 4) {
            holder.shijianTv.setTextColor(Color.parseColor("#FF6422"));
        } else if (position == 6) {
            holder.shijianTv.setTextColor(Color.parseColor("#2E2E2E"));
        }
    }

    @Override
    public int getItemCount() {
        return 10;
    }


    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView shijianTv;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            shijianTv = (TextView) itemView.findViewById(R.id.shijian_tv);

        }
    }
}
